import { IUser } from "@/api/service/user/types";
import { defineStore } from "pinia";

interface Menu {
  id: string;
  label: string;
  children: Menu[];
}
interface Paths {
  [key: string]: string;
}
interface UserStore {
  paths: Paths[];
  menus: Menu[];
  user: IUser;
  roleGroup: string;
  oss: boolean;
  token: string;
}

export const userStore = defineStore("user", {
  state: (): UserStore => {
    return {
      user: {
        platform: "",
        userName: "",
        nickName: "",
        telephone: "",
        roles: [],
        roleIds: [],
        deptId: "",
        storeNo: "",
        storeName: ""
      },
      /* 用户的token */
      token: "",
      paths: [],
      oss: false,
      menus: [],
      roleGroup: ""
    };
  },
  persist: true
});
export default {
  userStore
};
